Skip to content

refactor: rename dispatch kwarg sync= to force_sync=#14882

Open
valentijnscholten wants to merge 1 commit into
DefectDojo:devfrom
valentijnscholten:refactor/rename-sync-to-force-sync
Open

refactor: rename dispatch kwarg sync= to force_sync=#14882
valentijnscholten wants to merge 1 commit into
DefectDojo:devfrom
valentijnscholten:refactor/rename-sync-to-force-sync

Conversation

@valentijnscholten
Copy link
Copy Markdown
Member

@valentijnscholten valentijnscholten commented May 15, 2026

Summary

  • in perf(watson): prefetch relations + force async indexing #14881 we introduce force_async which made me realize we should use force_sync=True instead of sync=True. IS more explicit and clear what it does.
  • Rename the dispatch control kwarg sync=force_sync= on dojo_dispatch_task / dojo_async_task / we_want_async.
  • Hard rename — no alias period.

Why

  • The bare name sync collides with unrelated parameters elsewhere in the codebase (e.g. JIRA_Instance.finding_jira_sync, is_keep_in_sync, scan types named "HawkScan"), making code search and review confusing.
  • A recently-introduced force_async=True kwarg solves the inverse problem (always run in background). force_sync is the symmetric, intention-revealing name for the existing flag — readers instantly know what "force" means relative to the default async-when-possible behavior.

Changes

Caller / dispatch chain:

Tests:

Test plan

  • ruff check clean on all changed files.
  • pytest unittests/test_async_delete.py::TestAsyncDelete::test_async_delete_accepts_force_sync_kwarg — passes.
  • Pre-existing failures in test_reimport_prefetch.py reproduce on dev baseline → not caused by this change (verified by stashing the diff and re-running).

Notes

The `sync=True` kwarg on dojo_dispatch_task / dojo_async_task forces the
target task to run in the foreground. The bare name `sync` collides with
unrelated `sync` parameters elsewhere in the codebase (e.g. JIRA Instance's
`finding_jira_sync`, `is_keep_in_sync`) and is asymmetric with the
recently-introduced `force_async=True` knob. Rename to `force_sync=` for
clarity and symmetry.

Hard rename — no alias. Callers updated:
- dojo/decorators.py — we_want_async reads `force_sync` instead of `sync`.
- dojo/celery_dispatch.py — docstring.
- dojo/celery.py — DojoAsyncTask.apply_async pops `force_sync` from kwargs.
- dojo/importers/default_importer.py, default_reimporter.py — propagate
  `force_sync` from importer kwargs to post_process_findings_batch.
- dojo/finding/helper.py — post_process_findings_batch signature + nested
  dojo_dispatch_task(calculate_grade, ..., force_sync=force_sync).
- dojo/api_v2/serializers.py, dojo/finding_group/views.py — JIRA push
  call sites that want foreground execution.
- unittests/test_async_delete.py, test_reimport_prefetch.py,
  test_update_import_history.py — updated kwargs + docstrings.
@valentijnscholten valentijnscholten added the affects_pro PRs that affect Pro and need a coordinated release/merge moment. label May 15, 2026
@valentijnscholten valentijnscholten added this to the 2.59.0 milestone May 16, 2026
Copy link
Copy Markdown
Contributor

@mtesauro mtesauro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

@Maffooch Maffooch requested review from Jino-T and blakeaowens May 19, 2026 02:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

affects_pro PRs that affect Pro and need a coordinated release/merge moment. apiv2 unittests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants